﻿using Microsoft.Extensions.Configuration;
using StarsAdmin.Core.App.Models;
using StarsAdmin.Core.Helpers;

namespace StarsAdmin.Core.App
{
    public class AppConfigs
    {
        private readonly IConfiguration _configuration;

        public AppConfigs(IConfiguration configuration)
        {
            _configuration = configuration.NotNull();
            Initialize();
        }

        private void Initialize()
        {
            _jwt = new Jwt(_configuration);
            _cors = new Cors(_configuration);
            _sql = new Sql(_configuration);
            _snowIdOptions = new SnowIdOptions(_configuration);
            _snowFlakeWorkerId = int.Parse(_configuration.GetSection("SnowFlakeWorkerIdConfiguration").Value.NotNull());
        }

        private static Jwt _jwt;
        private static Cors _cors;
        private static Sql _sql;
        private static SnowIdOptions _snowIdOptions;
        private static int _snowFlakeWorkerId;
        public static Jwt Jwt { get => _jwt; }
        public static Cors Cors { get => _cors; }
        public static Sql Sql { get => _sql; }
        public static SnowIdOptions SnowIdOptions { get => _snowIdOptions; }
        public static int SnowFlakeWorkerId { get => _snowFlakeWorkerId; }
    }
}